{include file="public/head"}
<style>
    .x-body {
        min-width: 900px;
    }

    body {
        overflow-x: scroll;
    }
</style>
<body>
<div class="x-body">
    <div class="lotus-nav">

        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="start" name="start" value="{$Think.get.start}"
                   placeholder="开始日期">
        </div>

        <div class="layui-input-inline">
            <input type="text" class="layui-input" id="end" name="end" value="{$Think.get.end}" placeholder="结束日期">
        </div>

        <div class="layui-input-inline layui-form">
            <select name="audit" id="audit">
                <option value="">审核状态</option>
                <option value="1" {if $Think.get.audit eq 1} selected {/if}>未审核</option>
                <option value="2" {if $Think.get.audit eq 2} selected {/if}>已审核</option>
                <option value="3" {if $Think.get.audit eq 3} selected {/if}>未通过</option>
            </select>
        </div>

        <button class="layui-btn layui-btn-sm" onclick="search()">
            <i class="layui-icon layui-icon-search"></i>搜索
        </button>

        <span class="x-right">共有数据:<i class="i_count">{if count($list)>0}{$list->total()}{else/}0{/if}</i>条
        <button onclick="javascript:location.reload()" class="layui-btn-default ">
            <i class="layui-icon layui-icon-refresh"></i>
        </button>
        </span>
    </div>


    <table class="layui-table">
        <thead>
        <tr>
            <th style="width: 20px;text-align: center"></th>
            <th style="width: 70px;text-align:center">账单金额</th>
            <th>账单事由</th>
            <th style="width: 80px;text-align:center">账单分类</th>
            <th style="width: 80px;text-align:center">操作公司</th>
            <th style="width: 80px;text-align:center">审核状态</th>
            <th style="width: 120px;text-align:center">创建时间</th>
            <th style="width: 40px;text-align:center">操作</th>
        </tr>
        </thead>
        <tbody>
        {if count($list)>0}
        {volist name="list" id="vo"}
        <tr>
            <td style="text-align:center">{$i}</td>
            <td style="text-align:center">￥{$vo.money}</td>
            <td>{$vo.reason}</td>
            <td style="text-align:center">
                {switch name="vo.project" }
                {case value="1"}充值{/case}
                {case value="2"}支出{/case}
                {case value="3"}采购{/case}
                {case value="4"}运费{/case}
                {default /}其他
                {/switch}
            </td>
            <td style="text-align:center">{$vo.type == 1 ?'总公司':'子公司'}</td>
            <td style="text-align:center">
                {switch name="vo.audit" }
                {case value="1"}<b style="color: blue">未审核</b>{/case}
                {case value="2"}<b style="color: green">已审核</b>{/case}
                {case value="3"}<b style="color: red">未通过</b>{/case}
                {/switch}
            </td>
            <td style="text-align:center">{$vo['timestamp']|date="Y-m-d H:i",###}</td>
            <td style="text-align:center">
                <button class="layui-btn layui-btn-xs"
                        onclick="p_admin_show('详情','billInfo.html?id={$vo.id}')">详情
                </button>
            </td>
        </tr>
        {/volist}
        {else/}
        <tr>
            <td style="text-align: center;color:red" colspan="9">未找到符合条件的结果</td>
        </tr>
        {/if}
        </tbody>
    </table>
    {if count($list)>0}
    <div class="page">
        <div>
            {$list->render()}
        </div>
    </div>
    {/if}
</div>
</body>
{include file="public/foot"}
<script>
    function search() {
        var audit = $("#audit").val();
        var start = $("#start").val();
        var end = $("#end").val();
        location.href = "bill.html?audit=" + audit + "&start=" + start + "&end=" + end + "&purpose=" + '{$Think.get.purpose}' + "&company_id=" + '{$Think.get.company_id}' + "&type=" + '{$Think.get.type}';
    }

    layui.use(['laydate', 'form'], function () {
        var laydate = layui.laydate;
        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });
    function p_admin_show(title,url){
        parent.layer.open({
            type: 2,
            area: ['90%', '90%'],
            fix: false, //不固定
            maxmin: true,
            shadeClose: false,//是否点击遮罩关闭弹窗
            shade:0.2,
            resize:true,
            title: title,
            content: url
        });
    }
</script>
